import { _decorator, Component, find, instantiate, Node, Prefab } from 'cc';
import { MainLlogic } from '../MainLlogic';
const { ccclass, property } = _decorator;

@ccclass('CreateRanking')
export class CreateRanking extends Component {
    mainLogic:Node = null

    @property({type:Prefab})
    ranking:Prefab = null

    aaa= null


    start() {
        this.mainLogic = find('Canvas/MainLogic')
        this.node.on(Node.EventType.TOUCH_START,this.touchstart,this)
    }
    touchstart(){
        this.createrank()
    }

    createrank(){
        this.aaa = instantiate(this.ranking)
        this.node.getParent().addChild(this.aaa)
        this.aaa.setPosition(0,0,0)
    }

    update(deltaTime: number) {
        if(this.mainLogic.getComponent(MainLlogic).gameOver&&this.mainLogic.getComponent(MainLlogic).isRun){
            this.node.destroy()
        }
    }
}


